Skip to content

Conversation

@finger563
Copy link
Contributor

@finger563 finger563 commented Apr 11, 2025

Description

  • Add msx component using fmsx core
  • Modify fmsx core to use shared_memory component
  • Modify fmsx core to execute as a cart with interruptible execution
  • Add associated msx cart and update carts appropriately
  • Simplify gbc screenshot functionality
  • Modify fmsx core so that its Z80 implementation does not conflict with Genesis Z80 implementation
  • Update sdkconfig to reduce warnings but maintain performance.

Motivation and Context

MSX allows playing Metal Gear and Metal Gear 2: Solid Snake which are awesome ⚙️

How has this been tested?

Build and run main on BOX-3-EMU hardware and ensure all emulators still work, both metal gear games can run and they both have functional save/load state

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

mg2-compressed.mp4

image
image
image

image
image
image
image
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

* Add msx component using `fmsx` core
* Modify `fmsx` core to use `shared_memory` component
* Modify `fmsx` core to execute as a cart with interruptible execution
* Add associated msx cart and update carts appropriately
* Simplify gbc screenshot functionality
* Modify `fmsx` core so that its Z80 implementation does not conflict with Genesis Z80 implementation
* Update sdkconfig to reduce warnings but maintain performance.

MSX allows playing `Metal Gear` and `Metal Gear 2: Solid Snake` which are awesome ⚙️

Build and run `main` on BOX-3-EMU hardware and ensure all emulators still work, both metal gear games can run and they both have functional save/load state
@finger563 finger563 self-assigned this Apr 11, 2025
@finger563 finger563 added enhancement New feature or request emulation MSX labels Apr 11, 2025
@github-actions
Copy link

github-actions bot commented Apr 12, 2025

⚡ Static analysis result ⚡

🔴 cppcheck found 244 issues! Click here to see details.

printf("Num bytes allocated: %d\n", current_offset_);
// Use SIMD-accelerated memset from ESP32
// heap_caps_memset(memory_pool_, 0, TOTAL_MEMORY_SIZE);
memset(memory_pool_, 0, TOTAL_MEMORY_SIZE);
current_offset_ = 0;
}

!Line: 64 - portability: %d in format string (no. 1) requires 'int' but the argument type is 'size_t {aka unsigned long}'. [invalidPrintfArgType_sint]

register int J;
/* We only have 8 addressable ports */
R&=0x07;
switch(R)

!Line: 41 - style: The scope of the variable 'J' can be reduced. [variableScope]

color = color;
if (N)
XPal[N] = color;
else
XPal0 = color;
}

!Line: 253 - style: Redundant assignment of 'color' to itself. [selfAssignment]

byte *P;
if(ID<MAXDRIVES)
{
/* Get data pointer to requested sector */
P = LinearFDI(&FDD[ID],N);

!Line: 38 - style: The scope of the variable 'P' can be reduced. [variableScope]

byte *P;
if(ID<MAXDRIVES)
{
/* Get data pointer to requested sector */
P = LinearFDI(&FDD[ID],N);

!Line: 59 - style: The scope of the variable 'P' can be reduced. [variableScope]

byte Buf[512],Count,PS,SS,N,*P;
int J,I,Sector;
word Addr;
switch(R->PC.W-2)
{

!Line: 96 - style: The scope of the variable 'Count' can be reduced. [variableScope]

byte Buf[512],Count,PS,SS,N,*P;
int J,I,Sector;
word Addr;
switch(R->PC.W-2)
{

!Line: 96 - style: The scope of the variable 'PS' can be reduced. [variableScope]

byte Buf[512],Count,PS,SS,N,*P;
int J,I,Sector;
word Addr;
switch(R->PC.W-2)
{

!Line: 96 - style: The scope of the variable 'SS' can be reduced. [variableScope]

byte Buf[512],Count,PS,SS,N,*P;
int J,I,Sector;
word Addr;
switch(R->PC.W-2)
{

!Line: 96 - style: The scope of the variable 'N' can be reduced. [variableScope]

byte Buf[512],Count,PS,SS,N,*P;
int J,I,Sector;
word Addr;
switch(R->PC.W-2)
{

!Line: 96 - style: The scope of the variable 'P' can be reduced. [variableScope]

long Pos;
if(Verbose&0x04) printf("TAPE: Looking for header...");
R->AF.B.l|=C_FLAG;
if(CasStream)

!Line: 366 - style: The scope of the variable 'Pos' can be reduced. [variableScope]

long Pos;
R->AF.B.l|=C_FLAG;
if(CasStream)
{

!Line: 421 - style: The scope of the variable 'Pos' can be reduced. [variableScope]

byte *P;
if(ID<MAXDRIVES)
{
/* Get data pointer to requested sector */
P = LinearFDI(&FDD[ID],N);

!Line: 38 - style: Variable 'P' can be declared as pointer to const [constVariablePointer]

for(T=PP,J=0;*T&&(J<I);++J) T+=strlen(T)+1;
/* Delete cheat */
if(T) DelCheat(T);
break;
}
}

!Line: 437 - warning: Either the condition 'T' is redundant or there is possible null pointer dereference: T. [nullPointerRedundantCheck]

!Line: 439 - note: Assuming that condition 'T' is not redundant
!Line: 437 - note: Null pointer dereference

M&HUNT_16BIT? CON_CHECK:' ',
(M&HUNT_MASK_CHANGE)==HUNT_CONSTANT? CON_CHECK:' ',
(M&HUNT_MASK_CHANGE)==HUNT_PLUSONE? CON_CHECK:' ',
(M&HUNT_MASK_CHANGE)==HUNT_MINUSONE? CON_CHECK:' ',
(M&HUNT_MASK_CHANGE)==HUNT_PLUSMANY? CON_CHECK:' ',
(M&HUNT_MASK_CHANGE)==HUNT_MINUSMANY? CON_CHECK:' '

!Line: 510 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

sprintf(S+strlen(S),"%-9s %c\n",PP,M&(1<<J)? CON_CHECK:' ');
}
strcat(S," \nAdd cheats\n");
/* Number of shown locations */
K=J;

!Line: 579 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

if(F && (fwrite(Header,1,16,F)!=16)) { fclose(F);F=0; }
if(F && (fwrite(Buf,1,Size,F)!=Size)) { fclose(F);F=0; }
/* If failed writing state, delete open file */
if(F) fclose(F); else unlink(Name);

!Line: 274 - style: Condition 'F' is always true [knownConditionTrueFalse]

unsigned int LoadState(unsigned char *Buf,unsigned int MaxSize)
{
int State[256],J,I,K;
unsigned int Size;
/* No data read yet */

!Line: 127 - style: Parameter 'Buf' can be declared as pointer to const [constParameterPointer]

VDP[35]=(SY>>8) & 0x03;
VDP[38]=DY & 0xFF;
VDP[39]=(DY>>8) & 0x03;
}
else {
MMC.SY=SY;

!Line: 577 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

VDP[35]=(SY>>8) & 0x03;
VDP[38]=DY & 0xFF;
VDP[39]=(DY>>8) & 0x03;
}
else {
MMC.SY=SY;

!Line: 750 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

VDP[35]=(SY>>8) & 0x03;
VDP[38]=DY & 0xFF;
VDP[39]=(DY>>8) & 0x03;
}
else {
MMC.SY=SY;

!Line: 807 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

static int GetVdpTimingValue(register int *timing_values)
{
return(timing_values[((VDP[1]>>6)&1)|(VDP[8]&2)|((VDP[9]<<1)&4)]);
}
/** SrchEgine()** ********************************************/

!Line: 337 - style: Parameter 'timing_values' can be declared as pointer to const [constParameterPointer]

static char *Ops[16] =
{
"SET ","AND ","OR ","XOR ","NOT ","NOP ","NOP ","NOP ",
"TSET","TAND","TOR ","TXOR","TNOT","NOP ","NOP ","NOP "
};
static char *Commands[16] =

!Line: 874 - style: Variable 'Ops' can be declared as const array [constVariable]

static char *Commands[16] =
{
" ABRT"," ????"," ????"," ????","POINT"," PSET"," SRCH"," LINE",
" LMMV"," LMMM"," LMCM"," LMMC"," HMMV"," HMMM"," YMMM"," HMMC"
};
register byte CL, CM, LO;

!Line: 879 - style: Variable 'Commands' can be declared as const array [constVariable]

register byte X,*T,*R,C;
byte ZBuf[304];
P=RefreshBorder512(Y,XPal[BGColor&0x03]);
if(!P) return;

!Line: 73 - style: The scope of the variable 'T' can be reduced. [variableScope]

register byte C,X,*T,*R;
byte ZBuf[304];
P=RefreshBorder512(Y,XPal[BGColor]);
if(!P) return;

!Line: 107 - style: The scope of the variable 'T' can be reduced. [variableScope]

register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder512(Y,BC);
if(!P) return;

!Line: 141 - style: The scope of the variable 'T' can be reduced. [variableScope]

register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder512(Y,BC);
if(!P) return;

!Line: 141 - style: The scope of the variable 'C' can be reduced. [variableScope]

register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder512(Y,BC);
if(!P) return;

!Line: 141 - style: The scope of the variable 'G' can be reduced. [variableScope]

register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder512(Y,BC);
if(!P) return;

!Line: 141 - style: Variable 'C' can be declared as pointer to const [constVariablePointer]

register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder512(Y,BC);
if(!P) return;

!Line: 141 - style: Variable 'G' can be declared as pointer to const [constVariablePointer]

int main(int argc,char *argv[])
{
int CartCount,TypeCount;
int JoyCount,DiskCount[2];
char *P;
int N,J;

!Line: 51 - style: Parameter 'argv' can be declared as const array [constParameter]

char *P;
int N,J;
#ifdef DEBUG
CPU->Trap = 0xFFFF;
CPU->Trace = 0;

!Line: 55 - style: Unused variable: P [unusedVariable]

register byte X,*T,*G;
BC=XPal[BGColor];
P=RefreshBorder(Y,BC);
if(!P) return;

!Line: 457 - style: The scope of the variable 'T' can be reduced. [variableScope]

register byte K,X,*T,*G;
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;
if(!ScreenON) ClearLine(P,XPal[BGColor]);

!Line: 492 - style: The scope of the variable 'T' can be reduced. [variableScope]

register byte K,X,*T;
register int I,J;
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;

!Line: 527 - style: The scope of the variable 'T' can be reduced. [variableScope]

register int I,J;
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;
if(!ScreenON) ClearLine(P,XPal[BGColor]);

!Line: 528 - style: The scope of the variable 'I' can be reduced. [variableScope]

register int I,J;
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;
if(!ScreenON) ClearLine(P,XPal[BGColor]);

!Line: 528 - style: The scope of the variable 'J' can be reduced. [variableScope]

register byte X,K,*T,*G;
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;
if(!ScreenON) ClearLine(P,XPal[BGColor]);

!Line: 564 - style: The scope of the variable 'T' can be reduced. [variableScope]

register byte K,X,C,*T,*R;
register int I,J;
byte ZBuf[320];
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;

!Line: 594 - style: The scope of the variable 'T' can be reduced. [variableScope]

register int I,J;
byte ZBuf[320];
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;

!Line: 595 - style: The scope of the variable 'I' can be reduced. [variableScope]

register int I,J;
byte ZBuf[320];
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;

!Line: 595 - style: The scope of the variable 'J' can be reduced. [variableScope]

register byte I,X,*T,*R;
byte ZBuf[320];
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;

!Line: 637 - style: The scope of the variable 'T' can be reduced. [variableScope]

register byte C,X,*T,*R;
byte ZBuf[320];
P=RefreshBorder(Y,BPal[VDP[7]]);
if(!P) return;

!Line: 684 - style: The scope of the variable 'T' can be reduced. [variableScope]

register int J,K;
byte ZBuf[320];
P=RefreshBorder(Y,BPal[VDP[7]]);
if(!P) return;

!Line: 719 - style: The scope of the variable 'J' can be reduced. [variableScope]

register int J,K;
byte ZBuf[320];
P=RefreshBorder(Y,BPal[VDP[7]]);
if(!P) return;

!Line: 719 - style: The scope of the variable 'K' can be reduced. [variableScope]

register byte C,X,*T,*R;
register int J,K;
byte ZBuf[320];
P=RefreshBorder(Y,BPal[VDP[7]]);
if(!P) return;

!Line: 761 - style: The scope of the variable 'T' can be reduced. [variableScope]

register int J,K;
byte ZBuf[320];
P=RefreshBorder(Y,BPal[VDP[7]]);
if(!P) return;

!Line: 762 - style: The scope of the variable 'J' can be reduced. [variableScope]

register int J,K;
byte ZBuf[320];
P=RefreshBorder(Y,BPal[VDP[7]]);
if(!P) return;

!Line: 762 - style: The scope of the variable 'K' can be reduced. [variableScope]

register byte *P,*PT,*AT;
register int L,K;
register unsigned int M;
/* No extra sprites yet */
VDPStatus[0]&=~0x5F;

!Line: 256 - style: Variable 'PT' can be declared as pointer to const [constVariablePointer]

register byte X,*T,*G;
BC=XPal[BGColor];
P=RefreshBorder(Y,BC);
if(!P) return;

!Line: 457 - style: Variable 'G' can be declared as pointer to const [constVariablePointer]

register byte K,X,*T,*G;
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;
if(!ScreenON) ClearLine(P,XPal[BGColor]);

!Line: 492 - style: Variable 'G' can be declared as pointer to const [constVariablePointer]

register byte X,K,*T,*G;
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;
if(!ScreenON) ClearLine(P,XPal[BGColor]);

!Line: 564 - style: Variable 'G' can be declared as pointer to const [constVariablePointer]

if(F && (fwrite(Header,1,16,F)!=16)) { fclose(F);F=0; }
if(F && (fwrite(Buf,1,Size,F)!=Size)) { fclose(F);F=0; }
/* If failed writing state, delete open file */
if(F) fclose(F); else unlink(Name);

!Line: 274 - style: Condition 'F' is always true [knownConditionTrueFalse]

!Line: 264 - note: Assuming condition '!F' is false
!Line: 274 - note: Condition 'F' is always true

if(sscanf(S,"%08X %d",&J,&I)==2)
if(K==J) { Result=I;break; }
/* Done with the file */
fclose(F);
}

!Line: 2809 - warning: %X in format string (no. 1) requires 'unsigned int *' but the argument type is 'signed int *'. [invalidScanfArgType_int]

if(fgets(Buf,sizeof(Buf),F) && (sscanf(Buf,"%13s",S)==1))
AddCheat(S);
/* Done with the file */
fclose(F);

!Line: 3362 - warning: inconclusive: Width 13 given in format string (no. 1) is smaller than destination buffer 'S[16]'. [invalidScanfFormatWidth_smaller]

for(J=0;J<MAXCARTS;++J) LoadCart(ROMName[J],J,ROMGUESS(J)|ROMTYPE(J));
/* Open stream for a printer */
if(Verbose)
printf("Redirecting printer output to %s...OK\n",PrnName? PrnName:"STDOUT");
ChangePrinter(PrnName);

!Line: 557 - style: Variable 'J' is reassigned a value before the old one has been used. [redundantAssignment]

!Line: 548 - note: J is assigned
!Line: 557 - note: J is overwritten

for(J=0;J<MAXCARTS;++J) LoadCart(ROMName[J],J,ROMGUESS(J)|ROMTYPE(J));
/* Open stream for a printer */
if(Verbose)
printf("Redirecting printer output to %s...OK\n",PrnName? PrnName:"STDOUT");
ChangePrinter(PrnName);

!Line: 557 - style: Variable 'J' is reassigned a value before the old one has been used. [redundantAssignment]

!Line: 549 - note: J is assigned
!Line: 557 - note: J is overwritten

FILE *F;
int J;
/* CMOS.ROM is saved in the program directory */
if(ProgDir && chdir(ProgDir))
{ if(Verbose) printf("Failed changing to '%s' directory!\n",ProgDir); }

!Line: 619 - style: The scope of the variable 'F' can be reduced. [variableScope]

int J,I;
/* If changing hardware model, load new system ROMs */
if((Mode^NewMode)&MSX_MODEL)
{
/* Change to the program directory */

!Line: 700 - style: The scope of the variable 'I' can be reduced. [variableScope]

int DX,DY,L,J;
/* Number of a joystick port */
Port = (PSG->R[15]&0x40)>>6;
L = JOYTYPE(Port);

!Line: 1162 - style: The scope of the variable 'DX' can be reduced. [variableScope]

int DX,DY,L,J;
/* Number of a joystick port */
Port = (PSG->R[15]&0x40)>>6;
L = JOYTYPE(Port);

!Line: 1162 - style: The scope of the variable 'DY' can be reduced. [variableScope]

register byte I,J;
Port&=0xFF;
switch(Port)
{

!Line: 1238 - style: The scope of the variable 'I' can be reduced. [variableScope]

register byte J,I;
if(PSLReg!=V)
for(PSLReg=V,J=0;J<4;++J,V>>=2)
{
I = J<<1;

!Line: 1759 - style: The scope of the variable 'J' can be reduced. [variableScope]

register byte J,I;
if(PSLReg!=V)
for(PSLReg=V,J=0;J<4;++J,V>>=2)
{
I = J<<1;

!Line: 1759 - style: The scope of the variable 'I' can be reduced. [variableScope]

register byte J,I;
/* Cartridge slots do not have subslots, fix them at 0:0:0:0 */
if((PSL[3]==1)||(PSL[3]==2)) V=0x00;
/* In MSX1, slot 0 does not have subslots either */
if(!PSL[3]&&((Mode&MSX_MODEL)==MSX_MSX1)) V=0x00;

!Line: 1779 - style: The scope of the variable 'J' can be reduced. [variableScope]

register byte J,I;
/* Cartridge slots do not have subslots, fix them at 0:0:0:0 */
if((PSL[3]==1)||(PSL[3]==2)) V=0x00;
/* In MSX1, slot 0 does not have subslots either */
if(!PSL[3]&&((Mode&MSX_MODEL)==MSX_MSX1)) V=0x00;

!Line: 1779 - style: The scope of the variable 'I' can be reduced. [variableScope]

static time_t PrevTime;
static struct tm TM;
register byte J;
time_t CurTime;
/* Only 16 registers/mode */

!Line: 1979 - style: The scope of the variable 'PrevTime' can be reduced. [variableScope]

static struct tm TM;
register byte J;
time_t CurTime;
/* Only 16 registers/mode */
R&=0x0F;

!Line: 1980 - style: The scope of the variable 'TM' can be reduced. [variableScope]

static byte BCount=0;
static int UCount=0;
static byte ACount=0;
static byte Drawing=0;
register int J;

!Line: 2034 - style: The scope of the variable 'BCount' can be reduced. [variableScope]

int J;
/* Try loading as a disk */
if(hasext(FileName,".DSK")||hasext(FileName,".FDI"))
{
/* Change disk image in drive A: */

!Line: 2474 - style: The scope of the variable 'J' can be reduced. [variableScope]

int J,I,K,Result,ROMCount[MAXMAPPERS];
char S[256];
FILE *F;
/* No result yet */
Result = -1;

!Line: 2790 - style: The scope of the variable 'K' can be reduced. [variableScope]

char S1[41],S2[41];
SHA1 C;
/* Compute ROM's SHA1 */
ResetSHA1(&C);
InputSHA1(&C,Buf,Size);

!Line: 2819 - style: The scope of the variable 'S2' can be reduced. [variableScope]

char *T;
FILE *F;
/* Slot number must be valid */
if((Slot<0)||(Slot>=MAXSLOTS)) return(0);
/* Find primary/secondary slots */

!Line: 3023 - style: The scope of the variable 'T' can be reduced. [variableScope]

char *MakeFileName(const char *Name,const char *Ext)
{
char *Result,*P1,*P2,*P3;
Result = malloc(strlen(Name)+strlen(Ext)+1);
if(!Result) return(0);

!Line: 2366 - style: inconclusive: Function 'MakeFileName' argument 1 names different: declaration 'FileName' definition 'Name'. [funcArgNamesDifferent]

!Line: 367 - note: Function 'MakeFileName' argument 1 names different: declaration 'FileName' definition 'Name'.
!Line: 2366 - note: Function 'MakeFileName' argument 1 names different: declaration 'FileName' definition 'Name'.

char *MakeFileName(const char *Name,const char *Ext)
{
char *Result,*P1,*P2,*P3;
Result = malloc(strlen(Name)+strlen(Ext)+1);
if(!Result) return(0);

!Line: 2366 - style: inconclusive: Function 'MakeFileName' argument 2 names different: declaration 'Extension' definition 'Ext'. [funcArgNamesDifferent]

!Line: 367 - note: Function 'MakeFileName' argument 2 names different: declaration 'Extension' definition 'Ext'.
!Line: 2366 - note: Function 'MakeFileName' argument 2 names different: declaration 'Extension' definition 'Ext'.

int SaveSTA(const char *Name)
{
static byte Header[16] = "STE\032\003\0\0\0\0\0\0\0\0\0\0\0";
unsigned int J,Size;
byte *Buf;
FILE *F;

!Line: 244 - style: inconclusive: Function 'SaveSTA' argument 1 names different: declaration 'FileName' definition 'Name'. [funcArgNamesDifferent]

!Line: 323 - note: Function 'SaveSTA' argument 1 names different: declaration 'FileName' definition 'Name'.
!Line: 244 - note: Function 'SaveSTA' argument 1 names different: declaration 'FileName' definition 'Name'.

int LoadSTA(const char *Name)
{
int Size,OldMode,OldRAMPages,OldVRAMPages;
byte Header[16],*Buf;
FILE *F;

!Line: 289 - style: inconclusive: Function 'LoadSTA' argument 1 names different: declaration 'FileName' definition 'Name'. [funcArgNamesDifferent]

!Line: 328 - note: Function 'LoadSTA' argument 1 names different: declaration 'FileName' definition 'Name'.
!Line: 289 - note: Function 'LoadSTA' argument 1 names different: declaration 'FileName' definition 'Name'.

case 0: Port=PSG->R[15]&(0x10<<Port)? 0x3F:J;break;
case 1: Port=(MouseDX[Port]>>4)|(J&0x30);break;
case 2: Port=(MouseDX[Port]&0x0F)|(J&0x30);break;
case 3: Port=(MouseDY[Port]>>4)|(J&0x30);break;
case 4: Port=(MouseDY[Port]&0x0F)|(J&0x30);break;
}

!Line: 1193 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

int *T,I,J,K;
byte *P;
word A;
/*** STARTUP CODE starts here: ***/

!Line: 416 - style: Variable 'T' can be declared as pointer to const [constVariablePointer]

char *P;
int J,N;
/* Table full: no more cheats */
if(CheatCount>=MAXCHEATS) return(0);

!Line: 2575 - style: Variable 'P' can be declared as pointer to const [constVariablePointer]

char *P;
/* No result yet */
J = 0;
/* Remove old state name */

!Line: 2970 - style: Variable 'P' can be declared as pointer to const [constVariablePointer]

char S[256],*P,*T,*H;
FILE *F;
int J,I;
if(!(F=fopen(Name,"rb"))) return(0);

!Line: 3382 - style: Variable 'H' can be declared as pointer to const [constVariablePointer]

word A;
/*** STARTUP CODE starts here: ***/
T=(int *)"\01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
#ifdef LSB_FIRST

!Line: 418 - style: Unused variable: A [unusedVariable]

V&=0x11;
return;
case 0x5FFE: /* Write 4Dh, then (5FFFh)=69h to enable SRAM */
case 0x5FFF: /* (5FFEh)=4Dh, then write 69h to enable SRAM */
FMPACKey=A&1? ((FMPACKey&0x00FF)|((int)V<<8))
: ((FMPACKey&0xFF00)|V);

!Line: 1725 - style: Variable 'V' is assigned a value that is never used. [unreadVariable]

if((J=fread(P,1,Size,F))!=Size)
{
if(!Buf) FreeMemory(P);
fclose(F);
return(0);
}

!Line: 2950 - style: Variable 'J' is assigned a value that is never used. [unreadVariable]

register byte X,*T,*R,C;
byte ZBuf[320];
P=RefreshBorder(Y,XPal[BGColor&0x03]);
if(!P) return;

!Line: 809 - style: The scope of the variable 'T' can be reduced. [variableScope]

register byte C,X,*T,*R;
byte ZBuf[320];
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;

!Line: 844 - style: The scope of the variable 'T' can be reduced. [variableScope]

register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder(Y,BC);
if(!P) return;

!Line: 878 - style: The scope of the variable 'T' can be reduced. [variableScope]

register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder(Y,BC);
if(!P) return;

!Line: 878 - style: The scope of the variable 'C' can be reduced. [variableScope]

register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder(Y,BC);
if(!P) return;

!Line: 878 - style: The scope of the variable 'G' can be reduced. [variableScope]

register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder(Y,BC);
if(!P) return;

!Line: 878 - style: Variable 'C' can be declared as pointer to const [constVariablePointer]

register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder(Y,BC);
if(!P) return;

!Line: 878 - style: Variable 'G' can be declared as pointer to const [constVariablePointer]

if(!J||!VideoImg) return(FileSelect? 0:Result);
/* Erase characters on BS */
if(J==0x08)
{
I--;
CONChar(X+I+1,Y+H-2,'_');

!Line: 891 - style: Condition 'FileSelect' is always true [knownConditionTrueFalse]

P[I]=N&(0x80>>I)? FG:BG;
}
K+=8;
if(X>Img->W-8)
{
K=0;Y+=8;

!Line: 492 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

for(I=0,K=*C;I<8;++I) P[I]=K&(0x80>>I)? FG:BG;
}
void CONPrintN(int X,int Y,const char *S,int N)
{
int J,X1;

!Line: 558 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

for(I=0;I<8;++I) P[I]=*C&(0x80>>I)? FG:BG;
K+=8;
if(X>=VideoW)
{
K=0;Y+=8;
if(Y>=VideoH) Y=0;

!Line: 609 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

register pixel *P,FC,BC;
register byte X,*T,*G;
BC=XPal[BGColor];
P=RefreshBorder(Y,BC);
if(!P) return;

!Line: 456 - style: The scope of the variable 'FC' can be reduced. [variableScope]

register pixel *P,FC,BC;
register byte K,X,*T,*G;
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;

!Line: 491 - style: The scope of the variable 'FC' can be reduced. [variableScope]

register pixel *P,FC,BC;
register byte K,X,*T,*G;
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;

!Line: 491 - style: The scope of the variable 'BC' can be reduced. [variableScope]

register pixel *P,FC,BC;
register byte K,X,*T;
register int I,J;
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;

!Line: 526 - style: The scope of the variable 'FC' can be reduced. [variableScope]

register pixel *P,FC,BC;
register byte K,X,*T;
register int I,J;
P=RefreshBorder(Y,XPal[BGColor]);
if(!P) return;

!Line: 526 - style: The scope of the variable 'BC' can be reduced. [variableScope]

register pixel *P,FC,BC;
register byte K,X,C,*T,*R;
register int I,J;
byte ZBuf[320];
P=RefreshBorder(Y,XPal[BGColor]);

!Line: 593 - style: The scope of the variable 'FC' can be reduced. [variableScope]

register pixel *P,FC,BC;
register byte K,X,C,*T,*R;
register int I,J;
byte ZBuf[320];
P=RefreshBorder(Y,XPal[BGColor]);

!Line: 593 - style: The scope of the variable 'BC' can be reduced. [variableScope]

register pixel *P,FC,BC;
register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder512(Y,BC);
if(!P) return;

!Line: 140 - style: The scope of the variable 'FC' can be reduced. [variableScope]

int I,J,K,C,L,Result;
FILE *F;
byte *P,*T;
/* Must have a disk to save */
if(!D->Data) return(0);

!Line: 691 - style: The scope of the variable 'K' can be reduced. [variableScope]

L = (L-0x100+N-1)/N;
/* Round up to the next power of two */
for(J=1;J<L;J<<=1);
//printf("Tracks=%d, Heads=%d, Sectors=%d, SectorSize=%d<%d\n",I,K,N,L,J);
if(D->Verbose && (L!=J))
printf("LoadFDI(): Adjusted %d-byte CPC disk sectors to %d bytes.\n",L,J);

!Line: 386 - warning: Either the condition '!N' is redundant or there is division by zero at line 386. [zerodivcond]

!Line: 394 - note: Assuming that condition '!N' is not redundant
!Line: 386 - note: Division by zero

byte *P = SeekFDI(D,I,J,I,J,K+1);
int L = D->SecSize<SecSize? D->SecSize:SecSize;
/* Write sector */
if(!P||!L||(fwrite(P,1,L,F)!=L)) return(FDI_SAVE_FAILED);
/* Pad sector to SecSize, if needed */
if((SecSize>L)&&fseek(F,SecSize-L,SEEK_CUR)) return(FDI_SAVE_FAILED);

!Line: 632 - style: Variable 'P' can be declared as pointer to const [constVariablePointer]

byte *P = SeekFDI(D,I,J,I,J,K+1);
int L = D->SecSize<SecSize? D->SecSize:SecSize;
/* Write sector */
if(!P||!L||(fwrite(P,1,L,F)!=L)) return(FDI_SAVE_FAILED);
/* Pad sector to SecSize, if needed */
if((SecSize>L)&&fseek(F,SecSize-L,SEEK_CUR)) return(FDI_SAVE_FAILED);

!Line: 665 - style: Variable 'P' can be declared as pointer to const [constVariablePointer]

D->EPeriod=(int)(1000000L*(J? J:0x10000)/D->Clock);
}
/* Exit if no envelope running */
if(!D->EPeriod) return;

!Line: 221 - error: Signed integer overflow for expression '1000000L*(J?J:0x10000)'. [integerOverflow]

D->R[R]=V&=0x0F;
/* Reset envelope */
D->ECount = 0;
D->EPhase = 0;
/* Compute changed channels mask */
for(J=0;J<AY8910_CHANNELS/2;++J)

!Line: 182 - style: Variable 'V' is assigned a value that is never used. [unreadVariable]

const byte *FE;
int J;
/* Search for the first zeroed entry */
for(Start=Start>=2? Start:2;Start<DSK_FAT_SIZE;Start++)
{

!Line: 65 - style: The scope of the variable 'FE' can be reduced. [variableScope]

int J;
/* Search for the first zeroed entry */
for(Start=Start>=2? Start:2;Start<DSK_FAT_SIZE;Start++)
{
/* FAT entry address */

!Line: 66 - style: The scope of the variable 'J' can be reduced. [variableScope]

byte *DE,*FE,*FE2,*P;
int I,J,Written;
/* Can't have ID that is out of bounds */
if((ID<1)||(ID>DSK_DIR_SIZE)) return(0);

!Line: 216 - style: The scope of the variable 'FE2' can be reduced. [variableScope]

byte *DE,*FE,*FE2,*P;
int I,J,Written;
/* Can't have ID that is out of bounds */
if((ID<1)||(ID>DSK_DIR_SIZE)) return(0);

!Line: 216 - style: The scope of the variable 'P' can be reduced. [variableScope]

int I,J,Read;
/* Can't have ID that is out of bounds */
if((ID<1)||(ID>DSK_DIR_SIZE)) return(0);
/* Get directory entry */

!Line: 277 - style: The scope of the variable 'I' can be reduced. [variableScope]

byte *DE,*FE,*FE2;
int J;
/* Can't have ID that is out of bounds */
if((ID<1)||(ID>DSK_DIR_SIZE)) return(0);

!Line: 319 - style: The scope of the variable 'FE2' can be reduced. [variableScope]

byte *FAT,*DIR,*DAT;
/* Allocate memory if needed */
if(!Dsk)
{
Dsk=(byte *)malloc(DSK_DISK_SIZE);

!Line: 89 - style: Variable 'DAT' can be declared as pointer to const [constVariablePointer]

struct dirent *DE;
FILE *F;
DIR *D;
int J,I;
/* Create disk image */

!Line: 372 - style: Variable 'DE' can be declared as pointer to const [constVariablePointer]

DAT = DIR + DSK_DIR_SIZE*32;
/* Clear disk image */
memset(Dsk,0x00,DSK_DISK_SIZE);
/* Boot sector parameters */

!Line: 101 - style: Variable 'DAT' is assigned a value that is never used. [unreadVariable]

if(!RPLData[WPtr1].Count[WPtr2] || (++WPtr2<RPL_RECSIZE))
{
/* Start filling up the new input record */
RPLData[WPtr1].JoyState[WPtr2] = Cmd;
RPLData[WPtr1].Count[WPtr2] = 1;

!Line: 152 - style: Condition '!RPLData[WPtr1].Count[WPtr2]' is always false [knownConditionTrueFalse]

!Line: 131 - note: Assuming that condition 'RPLData[WPtr1].Count[WPtr2]' is not redundant
!Line: 145 - note: Assuming condition is false
!Line: 152 - note: Condition '!RPLData[WPtr1].Count[WPtr2]' is always false

int RPLRecord(unsigned int Cmd) { return(RPLRecordKeys(Cmd,0,0)); }
/** RPLRecordKeys() ******************************************/
/** Record emulation state, keys, and joystick input for **/
/** replaying them back later. **/
/*************************************************************/

!Line: 74 - style: inconclusive: Function 'RPLRecord' argument 1 names different: declaration 'JoyState' definition 'Cmd'. [funcArgNamesDifferent]

!Line: 62 - note: Function 'RPLRecord' argument 1 names different: declaration 'JoyState' definition 'Cmd'.
!Line: 74 - note: Function 'RPLRecord' argument 1 names different: declaration 'JoyState' definition 'Cmd'.

int RPLRecordKeys(unsigned int Cmd,const unsigned char *Keys,unsigned int KeySize)
{
int J;
/* Insure that recording is initialized */
if(!SaveState || !LoadState || !StateSize) return(0);

!Line: 80 - style: inconclusive: Function 'RPLRecordKeys' argument 1 names different: declaration 'JoyState' definition 'Cmd'. [funcArgNamesDifferent]

!Line: 68 - note: Function 'RPLRecordKeys' argument 1 names different: declaration 'JoyState' definition 'Cmd'.
!Line: 80 - note: Function 'RPLRecordKeys' argument 1 names different: declaration 'JoyState' definition 'Cmd'.

register pixel *P,FC,BC;
register byte X,M,*T,*C,*G;
BC=XPal[BGColor];
P=RefreshBorder(Y,BC);
if(!P) return;

!Line: 877 - style: The scope of the variable 'FC' can be reduced. [variableScope]

WaveCH[Channel].Pos = Length? WaveCH[Channel].Pos%Length:0;
WaveCH[Channel].Count = 0;
WaveCH[Channel].Data = Data;
/* Call sound driver if present */
if(SndDriver.SetWave) (*SndDriver.SetWave)(Channel,Data,Length,Rate);

!Line: 265 - style: Condition 'Length' is always true [knownConditionTrueFalse]

!Line: 259 - note: Assuming that condition 'Length<=0' is not redundant
!Line: 265 - note: Condition 'Length' is always true

unsigned int I,J;
/* Channel and waveform length have to be valid */
if((Channel<0)||(Channel>=SND_CHANNELS)||(Length<=0)) return;
/* Set wave channel parameters */

!Line: 256 - style: The scope of the variable 'J' can be reduced. [variableScope]

int J,I;
/* Toggle logging if requested */
if(Switch==MIDI_TOGGLE) Switch=!Logging;
if((Switch==MIDI_ON)||(Switch==MIDI_OFF))

!Line: 382 - style: The scope of the variable 'J' can be reduced. [variableScope]

int J,I;
/* Toggle logging if requested */
if(Switch==MIDI_TOGGLE) Switch=!Logging;
if((Switch==MIDI_ON)||(Switch==MIDI_OFF))

!Line: 382 - style: The scope of the variable 'I' can be reduced. [variableScope]

int MIDIVolume,MIDINote,MIDIWheel;
/* If logging off, file closed, or invalid channel, drop out */
if(!Logging||!MIDIOut||(Channel>=MIDI_CHANNELS-1)||(Channel<0)) return;
/* Frequency must be in range */
if((Freq<MIDI_MINFREQ)||(Freq>MIDI_MAXFREQ)) Freq=0;

!Line: 459 - style: The scope of the variable 'MIDIVolume' can be reduced. [variableScope]

int MIDIVolume,MIDINote,MIDIWheel;
/* If logging off, file closed, or invalid channel, drop out */
if(!Logging||!MIDIOut||(Channel>=MIDI_CHANNELS-1)||(Channel<0)) return;
/* Frequency must be in range */
if((Freq<MIDI_MINFREQ)||(Freq>MIDI_MAXFREQ)) Freq=0;

!Line: 459 - style: The scope of the variable 'MIDINote' can be reduced. [variableScope]

int MIDIVolume,MIDINote,MIDIWheel;
/* If logging off, file closed, or invalid channel, drop out */
if(!Logging||!MIDIOut||(Channel>=MIDI_CHANNELS-1)||(Channel<0)) return;
/* Frequency must be in range */
if((Freq<MIDI_MINFREQ)||(Freq>MIDI_MAXFREQ)) Freq=0;

!Line: 459 - style: The scope of the variable 'MIDIWheel' can be reduced. [variableScope]

void SetSound(int Channel,int Type)
{
/* Channel has to be valid */
if((Channel<0)||(Channel>=SND_CHANNELS)) return;
/* Set wave channel type */

!Line: 203 - style: inconclusive: Function 'SetSound' argument 2 names different: declaration 'NewType' definition 'Type'. [funcArgNamesDifferent]

!Line: 94 - note: Function 'SetSound' argument 2 names different: declaration 'NewType' definition 'Type'.
!Line: 203 - note: Function 'SetSound' argument 2 names different: declaration 'NewType' definition 'Type'.

printf("IPS: Failed applying COPY patch #%d to 0x%X..0x%X of 0x%X bytes.\n",Count,J,J+N-1,Size);
if(fseek(F,N,SEEK_CUR)<0) break;
}
else if(fread(Data+J,1,N,F)==N)
{
// printf("IPS: Applied COPY patch #%d to 0x%X..0x%X.\n",Count,J,J+N-1);

!Line: 78 - warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]

printf("IPS: Failed reading COPY patch #%d from the file.\n",Count);
break;
}
}
else
{

!Line: 88 - warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]

if(Data) printf("IPS: Failed reading FILL patch #%d from the file.\n",Count);
break;
}
/* Compute fill length */
N = ((unsigned int)Buf[0]<<8)+Buf[1];

!Line: 98 - warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]

printf("IPS: Failed applying FILL patch #%d (0x%02X) to 0x%X..0x%X of 0x%X bytes.\n",Count,Buf[1],J,J+N-1,Size);
}
else
{
// printf("IPS: Applied FILL patch #%d (0x%02X) to 0x%X..0x%X.\n",Count,Buf[1],J,J+N-1);
memset(Data+J,Buf[2],N);

!Line: 111 - warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]

unsigned int Result,Count,J,N;
FILE *F;
F = fopen(FileName,"rb");
if(!F) return(0);

!Line: 47 - style: The scope of the variable 'J' can be reduced. [variableScope]

unsigned int Result,Count,J,N;
FILE *F;
F = fopen(FileName,"rb");
if(!F) return(0);

!Line: 47 - style: The scope of the variable 'N' can be reduced. [variableScope]

unsigned int K,L;
int J,I;
/* Scan active search entries */
for(J=I=0;J<Count;++J)
{

!Line: 112 - style: The scope of the variable 'K' can be reduced. [variableScope]

static char Buf[32];
HUNTEntry *HE;
/* Must have a valid entry */
if(!(HE=GetHUNT(N))) return(0);

!Line: 151 - style: Local variable 'Buf' shadows outer variable [shadowVariable]

!Line: 38 - note: Shadowed declaration
!Line: 151 - note: Shadow variable

HUNTEntry *HE;
/* Must have a valid entry */
if(!(HE=GetHUNT(N))) return(0);
/* Depending on cheat type... */

!Line: 152 - style: Variable 'HE' can be declared as pointer to const [constVariablePointer]

register int J;
register byte I;
/* Exit if no change */
if(V==D->R[R]) return;

!Line: 82 - style: The scope of the variable 'J' can be reduced. [variableScope]

if(!J&&(Y>=(H-(H>>3))))
{ if(X<W3) J|=BTN_SELECT|BTN_EXIT; else if(X>=W-W3) J|=BTN_START; }
/* Right upper corner of the screen is the fire buttons */
if(!J&&(X>=W-(W3>>1))&&(Y>=(H>>3))&&(Y<(H>>3)+W3+(W3>>3)))
{

!Line: 180 - style: Condition '!J' is always true [knownConditionTrueFalse]

!Line: 169 - note: Assignment 'J=0', assigned value is 0
!Line: 172 - note: Assuming condition is false
!Line: 180 - note: Condition '!J' is always true

if(!J&&(X>=W-(W3>>1))&&(Y>=(H>>3))&&(Y<(H>>3)+W3+(W3>>3)))
{
/* Fire buttons overlap */
if(Y<=(H>>3)+(W3>>1)+(W3>>3)) J|=BTN_FIREA;
if(Y>=(H>>3)+(W3>>1)) J|=BTN_FIREB;
}

!Line: 184 - style: Condition '!J' is always true [knownConditionTrueFalse]

!Line: 169 - note: Assignment 'J=0', assigned value is 0
!Line: 172 - note: Assuming condition is false
!Line: 184 - note: Condition '!J' is always true

for(I=J=0,S[1]='\0';KBDLines[I];++I,Y+=KEYSTEP,X+=KBDOffsets[I]-J*KEYSTEP)
for(J=0;KBDLines[I][J];++J,X+=KEYSTEP)
{
/* Draw key frame */
P = (pixel *)Img->Data
+ Img->L*(Y+(KEYSTEP-KEYSIZE)/2)

!Line: 701 - style: Variable 'J' is reassigned a value before the old one has been used. [redundantAssignment]

!Line: 694 - note: J is assigned
!Line: 701 - note: J is overwritten

int X0,Y0,AX,AY,W0,H0;
/* For every known button... */
for(J=Result=0;Buttons[J].Bit>-2;++J)
{
/* Compute finger position relative to the button */

!Line: 428 - style: The scope of the variable 'X0' can be reduced. [variableScope]

int X0,Y0,AX,AY,W0,H0;
/* For every known button... */
for(J=Result=0;Buttons[J].Bit>-2;++J)
{
/* Compute finger position relative to the button */

!Line: 428 - style: The scope of the variable 'Y0' can be reduced. [variableScope]

int Result,X0,Y0,X1,Y1,J,NeedFrame,NeedLabel;
Image Dirty;
/* Use default cue color, if requested */
if(TextColor<0) TextColor=CLR_CUES;

!Line: 751 - style: The scope of the variable 'X0' can be reduced. [variableScope]

int Result,X0,Y0,X1,Y1,J,NeedFrame,NeedLabel;
Image Dirty;
/* Use default cue color, if requested */
if(TextColor<0) TextColor=CLR_CUES;

!Line: 751 - style: The scope of the variable 'Y0' can be reduced. [variableScope]

int Result,X0,Y0,X1,Y1,J,NeedFrame,NeedLabel;
Image Dirty;
/* Use default cue color, if requested */
if(TextColor<0) TextColor=CLR_CUES;

!Line: 751 - style: The scope of the variable 'X1' can be reduced. [variableScope]

int Result,X0,Y0,X1,Y1,J,NeedFrame,NeedLabel;
Image Dirty;
/* Use default cue color, if requested */
if(TextColor<0) TextColor=CLR_CUES;

!Line: 751 - style: The scope of the variable 'Y1' can be reduced. [variableScope]

int Result,X0,Y0,X1,Y1,J,NeedFrame,NeedLabel;
Image Dirty;
/* Use default cue color, if requested */
if(TextColor<0) TextColor=CLR_CUES;

!Line: 751 - style: The scope of the variable 'NeedFrame' can be reduced. [variableScope]

int Result,X0,Y0,X1,Y1,J,NeedFrame,NeedLabel;
Image Dirty;
/* Use default cue color, if requested */
if(TextColor<0) TextColor=CLR_CUES;

!Line: 751 - style: The scope of the variable 'NeedLabel' can be reduced. [variableScope]

int SetFinButton(unsigned int Mask,const Image *Img,int X,int Y,int W,int H)
{
unsigned int Flags;
int I,J,Result;
/* Special Mask bits: make button invisible or disable it */

!Line: 385 - style: inconclusive: Function 'SetFinButton' argument 2 names different: declaration 'Src' definition 'Img'. [funcArgNamesDifferent]

!Line: 104 - note: Function 'SetFinButton' argument 2 names different: declaration 'Src' definition 'Img'.
!Line: 385 - note: Function 'SetFinButton' argument 2 names different: declaration 'Src' definition 'Img'.

J |= J&FFWDButtons? BTN_FFWD:0;
J |= J&MENUButtons? BTN_MENU:0;
/* Done, return simulated "joystick" state */
return(J);
}

!Line: 201 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

J |= J&MENUButtons? BTN_MENU:0;
/* Done, return simulated "joystick" state */
return(J);
}

!Line: 202 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

Result |= I|(I&FFWDButtons? BTN_FFWD:0)|(I&MENUButtons? BTN_MENU:0);
}
else
{
/* We are dealing with the joypad arrows here */
W0 = Buttons[J].W>>1;

!Line: 449 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

if(Buttons&(1<<J))
{
PenCues[J] = CueText;
CueSizes[J] = strlen(CueText)*CHRSIZE;
}

!Line: 302 - error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]

!Line: 301 - note: Assuming that condition 'J<sizeof(PenCues)/sizeof(PenCues[0])' is not redundant
!Line: 302 - note: Shift

void CONFrame(int X,int Y,int Width,int Height,pixel FGColor)
{
if(!VideoImg) return;
X = X<0? 0:X>=VideoW? VideoW-1:X;
Y = Y<0? 0:Y>=VideoH? VideoH-1:Y;

!Line: 453 - style: inconclusive: Function 'CONFrame' argument 5 names different: declaration 'BGColor' definition 'FGColor'. [funcArgNamesDifferent]

!Line: 77 - note: Function 'CONFrame' argument 5 names different: declaration 'BGColor' definition 'FGColor'.
!Line: 453 - note: Function 'CONFrame' argument 5 names different: declaration 'BGColor' definition 'FGColor'.

int J;
if(X<0) { W+=X;X=0; } else if(X+W>Img->W) W=Img->W-X;
if(Y<0) { H+=Y;Y=0; } else if(Y+H>Img->H) H=Img->H-Y;
if((W>0)&&(H>0))

!Line: 171 - style: The scope of the variable 'J' can be reduced. [variableScope]

pixel *P;
if(X<0) { W+=X;X=0; } else if(X+W>Img->W) W=Img->W-X;
if(Y<0) { H+=Y;Y=0; } else if(Y+H>Img->H) H=Img->H-Y;
if((W>0)&&(H>0))

!Line: 186 - style: The scope of the variable 'P' can be reduced. [variableScope]

unsigned int A,B,C,D,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
// Get fractional part of Y

!Line: 781 - style: The scope of the variable 'A' can be reduced. [variableScope]

unsigned int A,B,C,D,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
// Get fractional part of Y

!Line: 781 - style: The scope of the variable 'B' can be reduced. [variableScope]

unsigned int A,B,C,D,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
// Get fractional part of Y

!Line: 781 - style: The scope of the variable 'C' can be reduced. [variableScope]

unsigned int A,B,C,D,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
// Get fractional part of Y

!Line: 781 - style: The scope of the variable 'D' can be reduced. [variableScope]

unsigned int A,B,C,D,X1,X2,Y1,Y2,F1,F2;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
// Get fractional part of Y
Y1 = Y&0xFFFF;

!Line: 840 - style: The scope of the variable 'A' can be reduced. [variableScope]

unsigned int A,B,C,D,X1,X2,Y1,Y2,F1,F2;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
// Get fractional part of Y
Y1 = Y&0xFFFF;

!Line: 840 - style: The scope of the variable 'B' can be reduced. [variableScope]

unsigned int A,B,C,D,X1,X2,Y1,Y2,F1,F2;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
// Get fractional part of Y
Y1 = Y&0xFFFF;

!Line: 840 - style: The scope of the variable 'C' can be reduced. [variableScope]

unsigned int A,B,C,D,X1,X2,Y1,Y2,F1,F2;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
// Get fractional part of Y
Y1 = Y&0xFFFF;

!Line: 840 - style: The scope of the variable 'D' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 954 - style: The scope of the variable 'A' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 954 - style: The scope of the variable 'B' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 954 - style: The scope of the variable 'C' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 954 - style: The scope of the variable 'D' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 954 - style: The scope of the variable 'NW' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 954 - style: The scope of the variable 'NE' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 954 - style: The scope of the variable 'SW' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 954 - style: The scope of the variable 'SE' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 954 - style: The scope of the variable 'X1' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1028 - style: The scope of the variable 'A' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1028 - style: The scope of the variable 'B' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1028 - style: The scope of the variable 'C' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1028 - style: The scope of the variable 'D' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1105 - style: The scope of the variable 'A' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1105 - style: The scope of the variable 'B' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1105 - style: The scope of the variable 'C' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1105 - style: The scope of the variable 'D' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1105 - style: The scope of the variable 'NW' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1105 - style: The scope of the variable 'NE' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1105 - style: The scope of the variable 'SW' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1105 - style: The scope of the variable 'SE' can be reduced. [variableScope]

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1105 - style: The scope of the variable 'X1' can be reduced. [variableScope]

W = (W-2)<<16;
DX = (W-0x10001+Dst->W)/Dst->W;
H = (H-2)<<16;
DY = (H-0x10001+Dst->H)/Dst->H;
for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))

!Line: 774 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

H = (H-2)<<16;
DY = (H-0x10001+Dst->H)/Dst->H;
for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))
{
unsigned int A,B,C,D,Y1;

!Line: 776 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

W = (W-2)<<16;
DX = (W-0x10001+Dst->W)/Dst->W;
H = (H-2)<<16;
DY = (H-0x10001+Dst->H)/Dst->H;
for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))

!Line: 833 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

H = (H-2)<<16;
DY = (H-0x10001+Dst->H)/Dst->H;
for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))
{
unsigned int A,B,C,D,X1,X2,Y1,Y2,F1,F2;

!Line: 835 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

W = (W-2)<<16;
DX = (W-0x10001+Dst->W)/Dst->W;
H = (H-2)<<16;
DY = (H-0x10001+Dst->H)/Dst->H;
for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))

!Line: 947 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

H = (H-2)<<16;
DY = (H-0x10001+Dst->H)/Dst->H;
for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))
{
unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;

!Line: 949 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

W = (W-2)<<16;
DX = (W-0x10001+Dst->W)/Dst->W;
H = (H-2)<<16;
DY = (H-0x10001+Dst->H)/Dst->H;
for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))

!Line: 1021 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

H = (H-2)<<16;
DY = (H-0x10001+Dst->H)/Dst->H;
for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))
{
unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;

!Line: 1023 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

W = (W-2)<<16;
DX = (W-0x10001+Dst->W)/Dst->W;
H = (H-2)<<16;
DY = (H-0x10001+Dst->H)/Dst->H;
for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))

!Line: 1098 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

H = (H-2)<<16;
DY = (H-0x10001+Dst->H)/Dst->H;
for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))
{
unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;

!Line: 1100 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

unsigned int A,B,C,D,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
// Get fractional part of Y

!Line: 781 - style: Local variable 'D' shadows outer variable [shadowVariable]

!Line: 760 - note: Shadowed declaration
!Line: 781 - note: Shadow variable

unsigned int A,B,C,D,X1,X2,Y1,Y2,F1,F2;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
// Get fractional part of Y
Y1 = Y&0xFFFF;

!Line: 840 - style: Local variable 'D' shadows outer variable [shadowVariable]

!Line: 819 - note: Shadowed declaration
!Line: 840 - note: Shadow variable

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 954 - style: Local variable 'D' shadows outer variable [shadowVariable]

!Line: 933 - note: Shadowed declaration
!Line: 954 - note: Shadow variable

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1028 - style: Local variable 'D' shadows outer variable [shadowVariable]

!Line: 1007 - note: Shadowed declaration
!Line: 1028 - note: Shadow variable

unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;
Y1 = Y&0xFFFF;

!Line: 1105 - style: Local variable 'D' shadows outer variable [shadowVariable]

!Line: 1084 - note: Shadowed declaration
!Line: 1105 - note: Shadow variable

register pixel *DP,*SP,*S;
register unsigned int DX,DY;
/* If not scaling image, use plain copy */
if((Dst->W==W)&&(Dst->H==H)) { IMGCopy(Dst,0,0,Src,X,Y,W,H,-1);return; }

!Line: 237 - style: Variable 'S' can be declared as pointer to const [constVariablePointer]

void TelevizeImage(Image *Img,int X,int Y,int W,int H)
{
#if defined(BPP32) || defined(BPP24) || defined(BPP16)
register pixel *P;
/* Check arguments, compute start pointer */

!Line: 269 - style: Parameter 'Img' can be declared as pointer to const [constParameterPointer]

void LcdizeImage(Image *Img,int X,int Y,int W,int H)
{
#if defined(BPP32) || defined(BPP24) || defined(BPP16)
register pixel *P;
/* Check arguments, compute start pointer */

!Line: 316 - style: Parameter 'Img' can be declared as pointer to const [constParameterPointer]

void RasterizeImage(Image *Img,int X,int Y,int W,int H)
{
#if defined(BPP32) || defined(BPP24) || defined(BPP16)
register pixel *P;
/* Check arguments, compute start pointer */

!Line: 362 - style: Parameter 'Img' can be declared as pointer to const [constParameterPointer]

void CMYizeImage(Image *Img,int X,int Y,int W,int H)
{
#if defined(BPP32) || defined(BPP24) || defined(BPP16)
register pixel *P,C;
/* Check arguments, compute start pointer */

!Line: 409 - style: Parameter 'Img' can be declared as pointer to const [constParameterPointer]

void RGBizeImage(Image *Img,int X,int Y,int W,int H)
{
#if defined(BPP32) || defined(BPP24) || defined(BPP16)
register pixel *P,C;
/* Check arguments, compute start pointer */

!Line: 469 - style: Parameter 'Img' can be declared as pointer to const [constParameterPointer]

void MonoImage(Image *Img,int X,int Y,int W,int H)
{
#if defined(BPP32) || defined(BPP24) || defined(BPP16)
register pixel *P,C;
/* Check arguments, compute start pointer */

!Line: 529 - style: Parameter 'Img' can be declared as pointer to const [constParameterPointer]

void SepiaImage(Image *Img,int X,int Y,int W,int H)
{
#if defined(BPP32) || defined(BPP24) || defined(BPP16)
register pixel *P,C;
register int R,G,B;

!Line: 580 - style: Parameter 'Img' can be declared as pointer to const [constParameterPointer]

void GreenImage(Image *Img,int X,int Y,int W,int H)
{
#if defined(BPP32) || defined(BPP24) || defined(BPP16)
register pixel *P,C;
/* Check arguments, compute start pointer */

!Line: 650 - style: Parameter 'Img' can be declared as pointer to const [constParameterPointer]

void AmberImage(Image *Img,int X,int Y,int W,int H)
{
#if defined(BPP32) || defined(BPP24) || defined(BPP16)
register pixel *P,C;
/* Check arguments, compute start pointer */

!Line: 701 - style: Parameter 'Img' can be declared as pointer to const [constParameterPointer]

for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))
{
unsigned int A,B,C,D,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;

!Line: 779 - style: Variable 'D' is assigned a value that is never used. [unreadVariable]

for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))
{
unsigned int A,B,C,D,X1,X2,Y1,Y2,F1,F2;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;

!Line: 838 - style: Variable 'D' is assigned a value that is never used. [unreadVariable]

for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))
{
unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;

!Line: 952 - style: Variable 'D' is assigned a value that is never used. [unreadVariable]

for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))
{
unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;

!Line: 1026 - style: Variable 'D' is assigned a value that is never used. [unreadVariable]

for(Y=0x10000,DP=D=(pixel *)Dst->Data;Y<H;Y+=DY,DP=(D+=Dst->L))
{
unsigned int A,B,C,D,P,NW,NE,SW,SE,X1,Y1;
// Compute new source pointer
SP = S+(Y>>16)*Src->L;

!Line: 1103 - style: Variable 'D' is assigned a value that is never used. [unreadVariable]

pixel *S,*D;
int DW,DY,J,I;
/* Check arguments */
if(W<0) { X+=W;W=-W; }
if(H<0) { Y+=H;H=-H; }

!Line: 1150 - style: The scope of the variable 'S' can be reduced. [variableScope]

pixel *S,*D;
int DW,DY,J,I;
/* Check arguments */
if(W<0) { X+=W;W=-W; }
if(H<0) { Y+=H;H=-H; }

!Line: 1150 - style: The scope of the variable 'D' can be reduced. [variableScope]

fprintf(F,"%d,%d,%d,%d,%s\n",0,Cheats[J].Addr,Cheats[J].Data,0,Cheats[J].Note);
/* Done */
fclose(F);
return(CheatCount);
}

!Line: 67 - warning: %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]

fprintf(F,"%d,%d,%d,%d,%s\n",0,Cheats[J].Addr,Cheats[J].Data,0,Cheats[J].Note);
/* Done */
fclose(F);
return(CheatCount);
}

!Line: 67 - warning: %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]

if(Switch==NET_TOGGLE) Switch=NETConnected()? NET_OFF:NET_ON;
switch(Switch)
{
case NET_OFF:
// Disconnect NetPlay

!Line: 47 - style: Condition 'NETConnected()' is always false [knownConditionTrueFalse]

!Line: 47 - note: Calling function 'NETConnected' returns 0
!Line: 47 - note: Condition 'NETConnected()' is always false

if(!NETMyName(T+1,sizeof(T)-1)) strcpy(T+1,"Network Play");
// Show "Connecting" message
CONMsg(-1,-1,-1,-1,NET_FGCOLOR,NET_OKCOLOR,T," \0 Connecting... \0 \0");
ShowVideo();
// Convert string to lower case, remove spaces
if(Switch==NET_SERVER)

!Line: 67 - style: Condition '!NETMyName(T+1,sizeof(T)-1)' is always true [knownConditionTrueFalse]

!Line: 67 - note: Calling function 'NETMyName' returns 0
!Line: 67 - note: Condition '!NETMyName(T+1,sizeof(T)-1)' is always true

if(NETRecv(In,N)!=N) return(0);
/* Success */
return(1);
}
/** NETJoystick() ********************************************/

!Line: 101 - style: Condition 'NETRecv(In,N)!=N' is always false [knownConditionTrueFalse]

!Line: 101 - note: Calling function 'NETRecv' returns 0
!Line: 101 - note: Condition 'NETRecv(In,N)!=N' is always false

if(NETExchange((char *)&I,(const char *)&J,sizeof(J)))
J = NETConnected()==NET_SERVER?
((J&(BTN_ALL|BTN_MODES))|((I&BTN_ALL)<<16))
: ((I&(BTN_ALL|BTN_MODES))|((J&BTN_ALL)<<16));
/* Done */

!Line: 123 - style: Condition 'NETExchange((char*)&I,(const char*)&J,sizeof(J))' is always false [knownConditionTrueFalse]

!Line: 123 - note: Calling function 'NETExchange' returns 0
!Line: 123 - note: Condition 'NETExchange((char*)&I,(const char*)&J,sizeof(J))' is always false

char S[256],T[256],*P;
int J;
// Toggle connection if requested
if(Switch==NET_TOGGLE) Switch=NETConnected()? NET_OFF:NET_ON;

!Line: 43 - style: The scope of the variable 'P' can be reduced. [variableScope]

int J;
// Toggle connection if requested
if(Switch==NET_TOGGLE) Switch=NETConnected()? NET_OFF:NET_ON;
switch(Switch)

!Line: 44 - style: The scope of the variable 'J' can be reduced. [variableScope]

const char *NETMyName(char *Buffer,int MaxChars) { return(0); }
int NETConnect(const char *Server,unsigned short Port) { return(NET_OFF); }
int NETConnectAsync(const char *Server,unsigned short Port) { return(0); }
int NETSend(const char *Out,int N) { return(0); }
int NETRecv(char *In,int N) { return(0); }
int NETBlock(int Switch) { return(NET_OFF); }

!Line: 26 - style: Parameter 'Buffer' can be declared as pointer to const [constParameterPointer]

int NETRecv(char *In,int N) { return(0); }
int NETBlock(int Switch) { return(NET_OFF); }
int NETConnected(void) { return(NET_OFF); }
void NETClose(void) { }
#endif

!Line: 30 - style: Parameter 'In' can be declared as pointer to const [constParameterPointer]

int J;
switch(A)
{
case WD1793_COMMAND:
/* Reset interrupt request */

!Line: 156 - style: The scope of the variable 'J' can be reduced. [variableScope]

unsigned int Load1793(register WD1793 *D,byte *Buf,unsigned int Size)
{
unsigned int N = (const byte *)&(D->Ptr) - (const byte *)D;
if(N>Size) return(0);
memcpy(D,Buf,N);
return(N);

!Line: 72 - style: Parameter 'Buf' can be declared as pointer to const [constParameterPointer]

case JR_NZ: if(R->AF.B.l&Z_FLAG) R->PC.W++; else { R->ICount-=5;M_JR; } break;
case JR_NC: if(R->AF.B.l&C_FLAG) R->PC.W++; else { R->ICount-=5;M_JR; } break;
case JR_Z: if(R->AF.B.l&Z_FLAG) { R->ICount-=5;M_JR; } else R->PC.W++; break;
case JR_C: if(R->AF.B.l&C_FLAG) { R->ICount-=5;M_JR; } else R->PC.W++; break;
case JP_NZ: if(R->AF.B.l&Z_FLAG) R->PC.W+=2; else { M_JP; } break;

!Line: 14 - error: syntax error: keyword 'if' is not allowed in global scope [syntaxError]

case RLC_xHL: I=msx_RdZ80(J.W);M_RLC(I);msx_WrZ80(J.W,I);break;
case RRC_xHL: I=msx_RdZ80(J.W);M_RRC(I);msx_WrZ80(J.W,I);break;
case RL_xHL: I=msx_RdZ80(J.W);M_RL(I);msx_WrZ80(J.W,I);break;
case RR_xHL: I=msx_RdZ80(J.W);M_RR(I);msx_WrZ80(J.W,I);break;
case SLA_xHL: I=msx_RdZ80(J.W);M_SLA(I);msx_WrZ80(J.W,I);break;
case SRA_xHL: I=msx_RdZ80(J.W);M_SRA(I);msx_WrZ80(J.W,I);break;

!Line: 14 - error: syntax error: keyword 'break' is not allowed in global scope [syntaxError]

case JR_NZ: if(R->AF.B.l&Z_FLAG) R->PC.W++; else { R->ICount-=5;M_JR; } break;
case JR_NC: if(R->AF.B.l&C_FLAG) R->PC.W++; else { R->ICount-=5;M_JR; } break;
case JR_Z: if(R->AF.B.l&Z_FLAG) { R->ICount-=5;M_JR; } else R->PC.W++; break;
case JR_C: if(R->AF.B.l&C_FLAG) { R->ICount-=5;M_JR; } else R->PC.W++; break;
case JP_NZ: if(R->AF.B.l&Z_FLAG) R->PC.W+=2; else { M_JP; } break;

!Line: 14 - error: syntax error: keyword 'if' is not allowed in global scope [syntaxError]

fflush(stdout);fflush(stdin);
if(!fgets(S,50,stdin)) return(1);
for(J=0;S[J]>=' ';J++)
S[J]=toupper(S[J]);

!Line: 340 - portability: fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux systems. [fflushOnInputStream]

case DB_FE: PatchZ80(R);break;
/*************************************************************/
case ADC_HL_BC: M_ADCW(BC);break;
case ADC_HL_DE: M_ADCW(DE);break;
case ADC_HL_HL: M_ADCW(HL);break;

!Line: 15 - error: syntax error: keyword 'break' is not allowed in global scope [syntaxError]

case RLC_B: M_RLC(R->BC.B.h);break; case RLC_C: M_RLC(R->BC.B.l);break;
case RLC_D: M_RLC(R->DE.B.h);break; case RLC_E: M_RLC(R->DE.B.l);break;
case RLC_H: M_RLC(R->HL.B.h);break; case RLC_L: M_RLC(R->HL.B.l);break;
case RLC_xHL: I=msx_RdZ80(R->HL.W);M_RLC(I);msx_WrZ80(R->HL.W,I);break;
case RLC_A: M_RLC(R->AF.B.h);break;

!Line: 14 - error: syntax error: keyword 'break' is not allowed in global scope [syntaxError]

if(J&BTN_SHIFT) J|=(J&BTN_ALT? (BTN_FIREB<<16):BTN_FIREB);
if(J&BTN_CONTROL) J|=(J&BTN_ALT? (BTN_FIREA<<16):BTN_FIREA);
/* Store joystick state for NetPlay transmission */
*(unsigned int *)&XKeyState[sizeof(XKeyState)-sizeof(int)]=J;

!Line: 194 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

if(J&BTN_CONTROL) J|=(J&BTN_ALT? (BTN_FIREA<<16):BTN_FIREA);
/* Store joystick state for NetPlay transmission */
*(unsigned int *)&XKeyState[sizeof(XKeyState)-sizeof(int)]=J;
/* If failed exchanging KeyStates with remote... */

!Line: 195 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

UseEffects^=Key&CON_ALT? EFF_SOFTEN:EFF_TVLINES;
SetEffects(UseEffects);
}
break;
case XK_F9:
if(!FastForward)

!Line: 358 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]


!Maximum character count per GitHub comment has been reached! Not all warnings/errors has been parsed!

@finger563 finger563 merged commit 43cb328 into main Apr 12, 2025
2 of 3 checks passed
@finger563 finger563 deleted the feat/msx branch April 12, 2025 20:50
@finger563 finger563 restored the feat/msx branch April 12, 2025 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emulation enhancement New feature or request MSX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants